#!/usr/bin/env python
# encoding: utf-8
'''
@author: zhaowenpeng
@contact: winston@peipeiyun.com
@software: garner
@file: temp_render.py
@time: 2020/8/10 2:00 下午
@desc:
'''



import os
from Cheetah.Template import Template
from .server import appid
import sys
sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__)))))
root = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))),appid)
def render(tmpnanme,**kwargs):
    filename = os.path.join(root,tmpnanme)
    template = Template(file=filename)
    template.outputEncoding='utf-8'
    if tmpnanme.endswith('html') or tmpnanme.endswith('tmpl'):
        template.__dict__.update(**kwargs)
    else:
        template.__dict__.update(**kwargs)
    return template.respond()

